﻿using GalaSoft.MvvmLight.Messaging;
using System.Windows;

namespace RandomMobileNumber.Views
{
    /// <summary>
    /// NumberPropertyWindow.xaml 的交互逻辑
    /// </summary>
    public partial class NumberPropertyWindow : Window
    {
        public NumberPropertyWindow()
        {
            InitializeComponent();

            Loaded += NumberPropertyWindow_Loaded;
            Closed += NumberPropertyWindow_Closed;
         
        }

        private void NumberPropertyWindow_Closed(object sender, System.EventArgs e)
        {
           
            Messenger.Default.Unregister<NotificationMessage>(this);
        }

        private void NumberPropertyWindow_Loaded(object sender, RoutedEventArgs e)
        {
            Messenger.Default.Register<NotificationMessage>(this, m =>
            {
                if (m.Notification.Equals("cancel"))
                {
                    this.DialogResult = false;
                    this.Close();
                }
                else if (m.Notification.Equals("ok"))
                {
                    this.DialogResult = true;
                    this.Close();
                }
            });
        }
    }
}
